/**
 * 
 */
package fr.toussna.service;

import java.util.List;

import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

import fr.toussna.entity.Category;

/**
 * @author My
 *
 */
public class LocalAccountService {
	
	public static AccountService getStub(){
		JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

    	//factory.getInInterceptors().add(new LoggingInInterceptor());
    	//factory.getOutInterceptors().add(new LoggingOutInterceptor());
    	factory.setServiceClass(AccountService.class);
    	factory.setAddress("http://localhost:9090/fo/ws/admin");
    	AccountService client = (AccountService) factory.create();
    	
    	return client;
		
	}
	
	public List<Category> getCategorie(){
		List<Category> list;
		AccountService client = LocalAccountService.getStub();
    	list = client.findAllCategories();
		return list;
	}
	
	
	public void deleteCategory(Category category){
		AccountService client = LocalAccountService.getStub();
    	client.deleteCategory(category);
		
	}
	
	public void createCategory(String name){
		AccountService client = LocalAccountService.getStub();
    	client.createCategory(new Category(name));
	}

}
